package com.ehotting.mqbd.zw.client.config;

import com.ehotting.mqbd.api.enums.DirectionEnum;
import com.ehotting.mqbd.api.enums.TopicEnum;
import com.ehotting.mqbd.api.bean.MqApplicationContext;
import com.ehotting.mqbd.core.config.MqbdCorePropertyConfig;
import com.ehotting.mqbd.core.helper.MQStringHelper;
import com.ehotting.mqbd.core.mq.consumer.MessageConsumer;
import com.ehotting.mqbd.zw.client.mq.MqTcpConsumerResponseAction;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

@Configuration
public class ZwConsumerResponseConfig {



    @DependsOn("mqbdCorePropertyConfig")
    @Bean(name="zwConcurrencyResponseMessageConsumer",initMethod = "start",destroyMethod = "shutdown")
    public MessageConsumer zwConcurrencyResponseMessageConsumer(MqbdCorePropertyConfig mqbdCorePropertyConfig,
                                                                MqTcpConsumerResponseAction mqTcpConsumerResponseAction,
                                                                MqApplicationContext mqApplicationContext){
        MessageConsumer messageConsumer = new MessageConsumer(
                mqbdCorePropertyConfig.getConsumer(),
                MQStringHelper.createConsumerGroupAtConsumerApp(TopicEnum.CONCURRENCY , mqApplicationContext , DirectionEnum.RESPONSE),
                mqTcpConsumerResponseAction);
        return messageConsumer;

    }

}
